package com.sbs.gaoxinqutoilet.adapter;


import android.view.View;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sbs.gaoxinqutoilet.R;
import com.sbs.gaoxinqutoilet.entity.BuildFileItemEntity;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by 聪明一只哈 on 2018/5/30.
 * Time: 2018/5/30  17:37
 */

public class ToiletFilesRvAdapter extends BaseQuickAdapter<BuildFileItemEntity.DataBean, ToiletFilesRvAdapter.BuyApplyViewHolder> {


    public ToiletFilesRvAdapter(@LayoutRes int layoutResId, @Nullable List<BuildFileItemEntity.DataBean> data) {
        super(layoutResId, data);
    }



    @Override
    protected void convert(BuyApplyViewHolder helper, BuildFileItemEntity.DataBean item) {


        helper.setText(R.id.item_tf_tv_name, item.getHuming());
        helper.setText(R.id.item_tf_buildtype, item.getGaizao_type_n());
        helper.setText(R.id.item_tf_address, item.getArea_name());


        if("是".equals(item.getXianzhi_n())){
            helper.setText(R.id.item_tf_statedesc, "闲置");
            helper.setImageResource(R.id.item_tf_image, R.drawable.xianzhi);
            helper.getView(R.id.arl_toilet_three).setVisibility(View.GONE);
        }else{
            helper.getView(R.id.arl_toilet_three).setVisibility(View.VISIBLE);
            helper.setText(R.id.item_tf_statedesc, item.getGaizao_state_n());
            switch (item.getGaizao_state_n()) {
                case "未改造":
                    helper.setImageResource(R.id.item_tf_image, R.drawable.unchang);
                    break;
                case "已改造":
                    helper.setImageResource(R.id.item_tf_image, R.drawable.changed);
                    break;
                case "改造中":
                    helper.setImageResource(R.id.item_tf_image, R.drawable.changing);
                    break;
                case "旧有改造":
                    helper.setImageResource(R.id.item_tf_image, R.drawable.nochange);
                    break;
                case "":
                case " ":
                    helper.setImageResource(R.id.item_tf_image, R.color.bt_translates);
                    break;
            }
        }

//        if ("0".equals(item.getXianzhi()) && !TextUtils.isEmpty(item.getGaizao_state_n())) {
//            helper.getView(R.id.arl_toilet_three_half).setVisibility(View.INVISIBLE);
//            helper.getView(R.id.arl_toilet_three).setVisibility(View.VISIBLE);
//            helper.setText(R.id.item_tf_statedesc, item.getGaizao_state_n());
//
//            switch (item.getGaizao_state_n()) {
//                case "未改造":
//                    helper.setImageResource(R.id.item_tf_image, R.drawable.unchang);
//                    break;
//                case "已改造":
//                    helper.setImageResource(R.id.item_tf_image, R.drawable.changed);
//                    break;
//                case "改造中":
//                    helper.setImageResource(R.id.item_tf_image, R.drawable.changing);
//                    break;
//            }
//        } else {
//            //!TextUtils.isEmpty(item.getGaizao_state_n()  必须有else情况,不然数据会出现错乱
//            helper.setImageResource(R.id.item_tf_image, R.color.bt_translates);
//            //helper.getView(R.id.item_tf_image).setVisibility(View.INVISIBLE);
//            //helper.setText(R.id.item_tf_statedesc, "异常数据");
//            helper.setText(R.id.item_tf_statedesc, "");
//        }

    }

    public class BuyApplyViewHolder extends BaseViewHolder {

        public BuyApplyViewHolder(View view) {
            super(view);
            AutoUtils.auto(view);
        }
    }
}
